<?php
namespace App\Controllers;
use \interop\Container\ContainerInterface as ContainerInterface;
use App\Models\UserModel;
use App\Models\OperaModel;
use pdo;
class DistributeController extends BaseController{
	public function distributeunfinish($request,$respone,$args){
		$user=new UserModel();
		$oper=new OperaModel();
		$ordernumber=$request->getParam('ordernumber');
		if($ordernumber==""){
		   if($user->getannounce()){
		    $data=json_encode($user->distributeunfinish());
		  }
		}else{
			$data=json_encode($oper->distributeunfinish($ordernumber));
		}
		  return $data;
     }
     public function distributedoing($request,$respone,$args){
		$user=new UserModel();
		$oper=new OperaModel();
		$ordernumber=$request->getParam('ordernumber');
		if($ordernumber==""){
		   if($user->getannounce()){
		    $data=json_encode($user->distributedoing());
		   }
		}else{
			$data=json_encode($oper->distributedoing($ordernumber));
		}
		  return $data;
     }
      public function distributefinished($request,$respone,$args){
		$user=new UserModel();
		$oper=new OperaModel();
		$ordernumber=$request->getParam('ordernumber');
		if($ordernumber==""){
		   if($user->getannounce()){
		    $data=json_encode($user->distributefinished());
		   }
		}else{
			$data=json_encode($oper->distributefinished($ordernumber));
		}
		  return $data;
     }
     public function distributemsg($request,$respone,$args){
     	$oper=new OperaModel();
	 	$id=$request->getParam('id');
	 	if($oper->distributemsg($id)){
     		$ret=json_encode($oper->distributemsg($id));
     		$data=array('message'=>"$ret",'code'=>0);
     	}else{
     		$data=array('message'=>'用户操作失败','code'=>101);
     	}
     	return $respone->withJSON($data);;
     }
    public function cakeEdit($request,$respone,$args){
    	include APP_PATH.'/Views/pages/cake/cake_edit.html';
    }
}

?>